﻿using Microsoft.Extensions.Logging;
using System;

namespace Atomic
{
    public interface IKestrelTrace : ILogger
    {
        void ConnectionAccepted(string connectionId);

        void ConnectionStart(string connectionId);

        void ConnectionStop(string connectionId);

        void ConnectionPause(string connectionId);//暂停

        void ConnectionResume(string connectionId);//恢复
        /// <summary>
        /// 连接被拒绝
        /// </summary>
        /// <param name="connectionId"></param>
        void ConnectionRejected(string connectionId);

        void ConnectionKeepAlive(string connectionId);
        /// <summary>
        /// 连接断开
        /// </summary>
        /// <param name="connectionId"></param>
        void ConnectionDisconnect(string connectionId);
        /// <summary>
        /// 请求处理错误
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="ex"></param>
        void RequestProcessingError(string connectionId, Exception ex);

        void ConnectionHeadResponseBodyWrite(string connectionId, long count);
        /// <summary>
        /// 并非所有连接都正常关闭
        /// </summary>
        void NotAllConnectionsClosedGracefully();
        /// <summary>
        /// 连接错误请求
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="ex"></param>
        void ConnectionBadRequest(string connectionId, Exception ex);
        /// <summary>
        /// 应用程序错误
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="traceIdentifier"></param>
        /// <param name="ex"></param>
        void ApplicationError(string connectionId, string traceIdentifier, Exception ex);
        /// <summary>
        /// 并非所有连接都已中止
        /// </summary>
        void NotAllConnectionsAborted();

        void HeartbeatSlow(TimeSpan heartbeatDuration, TimeSpan interval, DateTimeOffset now);

        void ApplicationNeverCompleted(string connectionId);
        /// <summary>
        /// 请求正文(数据包)开始
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="traceIdentifier"></param>
        void RequestBodyStart(string connectionId, string traceIdentifier);

        /// <summary>
        /// 请求正文(数据包)已完成
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="traceIdentifier"></param>
        void RequestBodyDone(string connectionId, string traceIdentifier);
        /// <summary>
        /// 请求正文未完全读取
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="traceIdentifier"></param>
        void RequestBodyNotEntirelyRead(string connectionId, string traceIdentifier);
        /// <summary>
        /// 请求速率超时
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="traceIdentifier"></param>
        void RequestBodyDrainTimedOut(string connectionId, string traceIdentifier);
        /// <summary>
        /// 请求不满足最小速度请求（默认为240字节/秒，宽限期为5秒）
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="traceIdentifier"></param>
        /// <param name="rate"></param>
        void RequestBodyMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier, double rate);
        /// <summary>
        /// 返回不满足最小速度请求（默认为240字节/秒，宽限期为5秒）
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="traceIdentifier"></param>
        void ResponseMinimumDataRateNotSatisfied(string connectionId, string traceIdentifier);
        /// <summary>
        /// 应用程序中止连接
        /// </summary>
        /// <param name="connectionId"></param>
        /// <param name="traceIdentifier"></param>
        void ApplicationAbortedConnection(string connectionId, string traceIdentifier);
    }
}
